package com.chinadci.smartcommunitysystembackstage.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chinadci.smartcommunitysystembackstage.entity.Clbx;
import com.chinadci.smartcommunitysystembackstage.entity.ScsHandle;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsAdmintypeMapper;
import com.chinadci.smartcommunitysystembackstage.mapper.ScsHandleMapper;
import com.chinadci.smartcommunitysystembackstage.util.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
@Service
public class ScsHandleService{
    @Autowired
    private ScsHandleMapper mapper;

    private Logger log= LoggerFactory.getLogger(this.getClass());

    //管理员处理报修时先查询是否处理过
    public ScsHandle Find(int id){
        log.info("=====管理员处理报修时先查询是否处理过");
        QueryWrapper<ScsHandle> qw=new QueryWrapper<>();
        qw.eq("r_id",id);
        return mapper.selectOne(qw);
    }

    //处理报修
    public int Update(Clbx cl){
        log.info("=====处理报修");
        QueryWrapper<ScsHandle> qw=new QueryWrapper<>();
        qw.eq("r_id",cl.getRid());
        ScsHandle scs=new ScsHandle();
        scs.setHState(0);
        scs.setAId(cl.getAid());
        scs.setHTime(DateTime.GetTime());
        return mapper.update(scs,qw);
    }
}
